using System;
using System.ComponentModel;
using System.Collections.Generic;

namespace shfa.snomtastic.data.business
{
	[DataObject(true)]
    public partial class FirmwareController
    {
	
		public SqlDataProvider DataProvider { get; set; }

        public FirmwareController()
        {
            DataProvider = new SqlDataProvider();
        }
	
		[DataObjectMethod(DataObjectMethodType.Insert, true)]
        public Guid InsertFirmware(FirmwareInfo oi)
		{
            return DataProvider.InsertFirmware(oi.ModelId, oi.ConfigurationId, oi.Version, oi.Description, oi.BootLoader, oi.UpgardeTo, oi.SendXML, oi.FileUrl);
		}

		[DataObjectMethod(DataObjectMethodType.Update, true)]
        public int UpdateFirmware(FirmwareInfo oi) 
		{
			return DataProvider.UpdateFirmware(oi.FirmwareId, oi.ModelId, oi.ConfigurationId, oi.Version, oi.Description, oi.BootLoader, oi.UpgardeTo, oi.SendXML, oi.FileUrl);
		}
		
		[DataObjectMethod(DataObjectMethodType.Delete, true)]
        public int DeleteFirmware(Guid firmwareId)
		{
			return DataProvider.DeleteFirmware(firmwareId);
        }

		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public FirmwareInfo SelectFirmware(Guid firmwareId)
        {    
			return ObjectFromDataRow(DataProvider.SelectFirmware(firmwareId));
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<FirmwareInfo> SelectFirmwares()
		{
            return ListFromDataTable(DataProvider.SelectFirmwares());
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, true)]
        public List<FirmwareInfo> SelectFirmwares(string sortExpression)
        {
            List<FirmwareInfo> retList = SelectFirmwares();
            if (sortExpression.Length > 0)
            {
                retList.Sort(new FirmwareComparer(sortExpression));
            }
            return retList;
        }

        [DataObjectMethod(DataObjectMethodType.Select, true)]
		public List<FirmwareInfo> SelectFirmwaresByConfiguration(Guid configurationId)
		{
			return ListFromDataTable(DataProvider.SelectFirmwaresByConfiguration(configurationId));
		}
		
        public List<FirmwareInfo> SelectFirmwaresByConfiguration(Guid configurationId,string sortExpression)
		{
			List<FirmwareInfo> retList = SelectFirmwaresByConfiguration(configurationId);
            if (sortExpression.Length > 0)
            {
                retList.Sort(new FirmwareComparer(sortExpression));
            }
            return retList;
		}

        [DataObjectMethod(DataObjectMethodType.Select, true)]
		public List<FirmwareInfo> SelectFirmwaresByModel(Guid modelId)
		{
			return ListFromDataTable(DataProvider.SelectFirmwaresByModel(modelId));
		}
		
        public List<FirmwareInfo> SelectFirmwaresByModel(Guid modelId,string sortExpression)
		{
			List<FirmwareInfo> retList = SelectFirmwaresByModel(modelId);
            if (sortExpression.Length > 0)
            {
                retList.Sort(new FirmwareComparer(sortExpression));
            }
            return retList;
		}

	}

}
		